ClassdescMP: Easy MPI Programming in C++
نویسندگان
چکیده
ClassdescMP is a distributed memory parallel programming system for use with C++ and MPI. It uses the Classdesc reflection system to ease the task of building complicated messages to be sent between processes. It doesn’t hide the underlying MPI API, so it is an augmentation of MPI capabilities. Users can still call standard MPI function calls if needed for performance reasons. 1 Classdesc Reflection MPI is an application programming interface (API in other words library of functions calls) for passing data from one unix process to another. The processes may be running on the same computer, or completely distinct computers, so this system provides a means of implementing distributed memory parallel processing. MPI has been used to great success in a variety of Engineering and Scientific codes where large arrays of the same type of data (eg floating point numbers) need to be exchanged between processes. However, with object oriented codes, one really needs to send objects (which may well be compound) between processes. MPI does provide the MPI_Type functionality, which allows the description of compound structures to be built up, however this is difficult to use, and doesn’t handle the case where the structure contains references to other objects (eg pointers). Object reflection allows straightforward implementation of serialisation (i.e. the creation of binary data representing objects that can be stored and later reconstructed), binding of scripting languages or GUI objects to ‘worker’ objects and remote method invocation. Serialisation, for example, requires knowledge of the detailed structure of the object. The member objects may be able to serialised (eg a dynamic array structure), but be implemented in terms of a pointer to a heap object. Also, one may be interested in serialising the object in a machine independent way, which requires knowledge of whether a particular bitfield is an integer or floating point variable. Languages such as Objective C give objects reflection by creating class objects and implicitly including an isa pointer in objects of that class pointing to the class object. Java does much the same thing, providing all objects with the native (i.e. non-Java) method getClass() which returns the object’s class at runtime, as maintained by the virtual machine. When using C++, on the other hand, at compile time most of the information about what exactly objects are is discarded. Standard C++ does provide a run-time type enquiry mechanism, however this is only required to return a unique signature for each type used in the program. Not only is this signature be compiler dependent, it could be implemented by the compiler enumerating all types used in a particular compilation, and so the signature would differ from program to program! The solution to this problem lies (as it must) outside the C++ language per se, in the form of a separate program (classdesc)[2,5] which parses an input program and emits function declarations that know about the structure of the objects inside. These are generically termed class descriptors. The class descriptor generator only needs to handle class, struct and union definitions. Anonymous structs used in typedefs are parsed as well. What is emitted in the object descriptor is a sequence of function calls for each base class and member, just as the compiler generated constructors and destructors are formed. Function overloading ensures that the correct sequence of actions is generated at compile time. Once a class definition has been parsed by classdesc, and the emitted class descriptors included into the original program, an object of that class can be serialised into a buffer object using the << operator. The >> operator can be used to extract the value back. #include "foo.h" //foo class definition #include "foo.cd" //foo class descriptor ... pack_t buf; foo a=...; bar b=...; foo c; buf << a << b; // serialise a into buffer. buf >> c; // unpack buffer into c. Now c == a. Once a buffer is packed, it can be saved to a file, or transferred over a network connection by using its public members data, which points to the data, and size which gives the number of bytes currently in the buffer. A variant of pack_t is the xdr_pack type, which uses the XDR library to represent the objects in a machine independent form. This is needed if the receiver of the serialised object is of a different architecture (eg endianess, or wordsize) to the sender. The only real reason for using MPI_Type in MPI is to support messages of compound objects between differing processors in a heterogenous cluster. xdr_pack gives heterogenous cluster support “for free”.
منابع مشابه
Classdesc and Graphcode: support for scientific programming in C++
Object-oriented programming languages such as Java and Objective C have become popular for implementing agent-based and other objectbased simulations since objects in those languages can reflect (i.e. make runtime queries of an object’s structure). This allows, for example, a fairly trivial serialisation routine (conversion of an object into a binary representation that can be stored or passed ...
متن کاملIntegrating MPI and the Nanothreads Programming Model
This paper presents a prototype runtime system that integrates MPI, used on distributed memory systems, and Nanothreads Programming Model (NPM), a programming model for shared memory multiprocessors. This integration does not alter the independence of the two models, since the runtime system is based on a multilevel design that supports each of them individually but offers the capability to com...
متن کاملOvercoming Distributed Debugging Challenges in the MPI+OpenMP Programming Model
There is a general consensus that exascale computing will employ a wide range of programming models to harness the many levels of architectural parallelism [1], including models to exploit parallelism in CPUs and devices, such as OpenMP. To aid programmers in managing the complexities arising from multiple programming models, debugging tools must enable programmers to identify errors at the lev...
متن کاملNew User-Guided and ckpt-Based Checkpointing Libraries for Parallel MPI Applications
We present design and implementation details as well as performance results for two new parallel checkpointing libraries developed by us for parallel MPI applications. The first one, a user-guided library requires from the programmer to support packing and unpacking code with an easy-to-use API using MPI constants. It uses MPI-2 collective I/O calls or a dedicated master process for checkpointi...
متن کاملMessage - Passing Interface for Microsoft Windows 3 . 1 A
Parallel computing offers the potential to push the performance of computer systems into new dimensions. Exploiting parallelism, concurrent tasks cooperate in solving huge computational problems. The theoretical foundations of parallel processing are wellestablished, and numerous types of parallel computers and environments are commercially available. The main obstacle for a broad application o...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2003